﻿project(eventadmin)

string(REGEX REPLACE "(.*)/(.*)/(.*)" "\\1" PROJECT_CTK_DIR  ${PROJECT_SOURCE_DIR})

set(PLUGIN_NAME org.commontk.eventadmin)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(BUILD_SHARED_LIBS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_CTK_DIR}/bin/cmake/debug/plugins)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_CTK_DIR}/bin/cmake/release/plugins)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_CTK_DIR}/bin/cmake/debug/plugins)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_CTK_DIR}/bin/cmake/release/plugins)

find_package(Qt5 REQUIRED COMPONENTS Widgets Core Gui Concurrent REQUIRED)
add_definitions(-DHAVE_QT5)

macro(SEARCH_FILE list dir)
    file(GLOB_RECURSE children "${dir}/*.h" "${dir}/*.hpp" "${dir}/*.c" "${dir}/*.cpp" "${dir}/*.ui")
    set(${list} ${children})
endmacro()
SEARCH_FILE(PLUGIN_RES_LIST ${PROJECT_CTK_DIR}/Plugins/${PLUGIN_NAME})

file(GLOB_RECURSE QRC_SOURCE_FILES ${PROJECT_CTK_DIR}/Plugins/${PLUGIN_NAME}/*.qrc)
qt5_add_resources(QRC_FILES ${QRC_SOURCE_FILES})

link_directories(debug ${PROJECT_CTK_DIR}/bin/cmake/debug
    optimized ${PROJECT_CTK_DIR}/bin/cmake/release)
include_directories(${PROJECT_CTK_DIR}/Libs/Core ${PROJECT_CTK_DIR}/Libs/PluginFramework)

add_library(${PROJECT_NAME} ${PLUGIN_RES_LIST} ${QRC_FILES})
add_dependencies(${PROJECT_NAME} PluginFramework Core)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent libPluginFramework.dll.a libCore.dll.a)


